package com.todo.sight.infrastructure.repository.impl;

import com.todo.common.common.enums.BizErrorCodeEnum;
import com.todo.common.common.exception.BizException;
import com.todo.sight.infrastructure.entity.po.PoiTypeRelationPO;
import com.todo.sight.infrastructure.mapper.PoiTypeRelationMapper;
import com.todo.sight.infrastructure.repository.PoiTypeRelationRepository;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (PoiTypeRelation)表服务实现类
 *
 * @author zhangwenxiang
 * @since 2024-03-04 21:10:04
 */
@Repository("poiTypeRelationRepository")
public class PoiTypeRelationRepositoryImpl implements PoiTypeRelationRepository {
    @Resource
    private PoiTypeRelationMapper poiTypeRelationMapper;


    @Override
    public Boolean insertPoiTypeRelationPO(PoiTypeRelationPO poiTypeRelationPO) {
        if (poiTypeRelationPO == null || poiTypeRelationPO.getPoiType() == null || poiTypeRelationPO.getBusinessId() == null || poiTypeRelationPO.getBizType() == null) {
            return false;
        }
        return poiTypeRelationMapper.insertPoiTypeRelationPO(poiTypeRelationPO) > 0;
    }

    @Override
    public Boolean removePoiTypeRelationPOById(Long id) {
        if (id == null || id < 0) {
            throw new BizException(BizErrorCodeEnum.PARAM_ERROR);
        }
        return poiTypeRelationMapper.removePoiTypeRelationPOById(id) > 0;
    }

    @Override
    public PoiTypeRelationPO queryPoiTypeRelationPOById(Long id) {
        if (id == null || id < 0) {
            return null;
        }
        return poiTypeRelationMapper.queryPoiTypeRelationPOById(id);
    }

    @Override
    public List<PoiTypeRelationPO> queryPoiTypeRelationListByPoi(Long poiId) {
        if (poiId == null || poiId < 0) {
            return Lists.newArrayList();
        }
        return poiTypeRelationMapper.queryPoiTypeRelationListByPoi(poiId);
    }

    @Override
    public List<PoiTypeRelationPO> queryPoiTypeRelationListByBizId(Long businessId) {
        if (businessId == null || businessId < 0) {
            return Lists.newArrayList();
        }
        return poiTypeRelationMapper.queryPoiTypeRelationListByBizId(businessId);
    }
}
